<form action="<?php echo U('Admin/Activity/Index/update')?>" id="update-activity">
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">活动标题<pub>*</pub>:</div>
        <div class="col-lg-3 col-md-5 col-xs-7 filed-from padding-none">
            <input name="title" value="<?php echo $data['title']?>" type="text" autocomplete="off" class="form-control radius-none _data" >
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">描述<pub>*</pub> :</div>
        <div class="col-lg-3 col-md-5 col-xs-7 filed-from padding-none">
            <textarea name="description" class="form-control radius-none _data"><?php echo $data['description']?></textarea>
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">活动详情<pub>*</pub>:</div>
        <div class="pull-left filed-from padding-none" style="width: 350px;">
            <textarea id="content"><?php echo $data['content']?></textarea>
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">活动缩略图<pub>*</pub> :</div>
        <div class="col-md-7 filed-from padding-none">
            <img class="thumb _thumb" data-toggle="tooltip" data-placement="top" title="允许上传 jpg , png " src="<?php echo cutUrl($data['thumb'],150,100);?>" width="150" height="100">
            <input type="hidden" name="thumb" value="<?php echo $data['thumb']?>" data-field="thumb" class="_data" />
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">活动图集<pub>*</pub> :</div>
        <div class="col-md-7 filed-from padding-none">
            <div id="slide_thumb">

                <?php foreach($data['images'] as $img):?>
                <img width="100" height="60" src="<?php echo cutUrl($img,100,60)?>" title="允许上传 jpg , png " data-placement="top" data-toggle="tooltip" style="margin: 5px 5px 0 0;" class="thumb _slide ">
                <?php endforeach;?>

            </div>
            <div id="slide_data">
                <?php foreach($data['images'] as $img):?>
                    <input class="_data" type="hidden" value="<?php echo $img?>" name="slide">
                <?php endforeach;?>
            </div>
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 padding-none lists">
        <div class="col-lg-2 col-md-3 col-xs-5 filed-name text-right">结束时间<pub>*</pub>:</div>
        <div class="col-lg-3 col-md-5 col-xs-7 filed-from padding-none">
            <input name="end_time" value="<?php echo $data['end_time']?>" id="end_time" type="text" class="form-control radius-none _data" >
        </div>
    </div>
    <div class="col-xs-12 col-md-12 col-lg-12 lists text-right">
        <input type="hidden" value="<?php echo $id?>" name="id" class="_data">
        <input type="submit" name="dosubmit" value="保存" class="btn btn-success radius-none">
        <input type="reset"  value="重置" class="btn btn-info radius-none">
    </div>
</form>
<script>


    $(function(){
        var ueditor;
        //加载百度编辑器
        Admin.getUeditor('content',function(ue){

            ueditor = ue;

        });

        //加载上传组建
        Admin.upload('._thumb');
        //选择多图
        Admin.upload('._slide',true);

        //提交数据
        $('#update-activity').unbind('submit');
        $('#update-activity').submit(function(){

            var _this = $(this);

            var action = _this.attr('action');

            var data = {};

            data.title = $('input[name=title]').val();
            data.content = ueditor.getContent();
            data.thumb = $('input[name=thumb]').val();
            data.images = [];
            data.end_time = $('input[name=end_time]').val();
            data.description = $('[name=description]').val();
            data.id = $('[name=id]').val();

            $('#slide_data > input[name=slide]').each(function(){

                data.images.push($(this).val());

            });


            $.post(action,{'data':data},function(result){

                var page = '<?php echo $page?>';

                var url = '';

                if(result.code == 200)
                    url = '<?php echo U("Admin/Activity/Index/lists")?>';

                showMessage(result.msg,result.code,url,{'page':page},2000);

            });


            return false;
        });
        //设置时间选择控件皮肤
        laydate({
            elem: '#end_time',
            format: 'YYYY-MM-DD hh:mm:ss', // 分隔符可以任意定义，该例子表示只显示年月
            festival: true,
            event: 'focus',
            min: '1970-00-00 00:00:00', //设定最小日期为当前日期
            max: '2099-06-16 23:59:59', //最大日期
            istime: true
        });


    })
    //图片上传回调
    function getImageSrc(_this){

        if(_this.length == 1){

            $('img._thumb').attr('src',cutUrl(_this[0],150,100));

            $('input[name="thumb"]').val(_this[0]);

        } else {

            var str = '';
            var thumb = '';
            for (var i in _this) {

                str += '<input type="hidden" name="slide" value="'+ _this[i] +'" class="_data" />';

                thumb += '<img class="thumb _slide " style="margin: 5px 5px 0 0;" data-toggle="tooltip" data-placement="top" title="允许上传 jpg , png " src="'+ cutUrl(_this[i],100,60) +'" width="100" height="60">';
            };

            $('#slide_thumb').html(thumb);
            $('#slide_data').html(str);

        }

    }
</script>